package composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wcj
 * @Date 2021/7/2 17:48
 * @Version 1.0
 */
public class ConcreteCompany implements Company {

    private String name;

    private List<Company> companyList = new ArrayList<>();

    public ConcreteCompany(String name) {
        this.name = name;
    }

    @Override
    public void add(Company company) {
        companyList.add(company);
    }

    @Override
    public void remove(Company company) {
        companyList.remove(company);
    }

    @Override
    public void display(int depth) {
        for (Company company : companyList) {
            company.display(0);
        }
    }

    @Override
    public void showDuty() {
        for (Company company : companyList) {
            company.showDuty();
        }
    }
}
